import {createApi, fetchBaseQuery} from "@reduxjs/toolkit/dist/query/react"
// debugger
const studentApi=createApi({
    reducerPath:'studentApi444444',
    baseQuery:fetchBaseQuery({
        baseUrl:'http://localhost:1337/api/'
    }),
    endpoints(build) {
        return {
            getStudents:build.query({
                query() {
                    return 'students'
                    //子路径
                },
                transformResponse(baseQueryReturnValue, meta, arg) {
                 console.log(baseQueryReturnValue.data,'----------')
                  return baseQueryReturnValue.data
                }
            }),
            getStudentsById:build.query(
                {
                    query(id) {
                        return `students/${id}`
                    },
                    transformResponse(baseQueryReturnValue, meta, arg) {
                     return baseQueryReturnValue.data
                    }
                }
            )
        }
    }
})
export const {useGetStudentsQuery,useGetStudentsByIdQuery}=studentApi
export  default  studentApi